using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyHocPhi.Model.Mapping
{
    public class PhiMacDinhMap : EntityTypeConfiguration<PhiMacDinh>
    {
        public PhiMacDinhMap()
        {
            // Primary Key
            this.HasKey(t => new { t.MaLopGoc, t.MaHocKy });

            // Properties
            this.Property(t => t.MaLopGoc)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.MaHocKy)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("PhiMacDinh");
            this.Property(t => t.MaLopGoc).HasColumnName("MaLopGoc");
            this.Property(t => t.MaHocKy).HasColumnName("MaHocKy");
            this.Property(t => t.HocPhi).HasColumnName("HocPhi");
            this.Property(t => t.LePhi).HasColumnName("LePhi");

            // Relationships
            this.HasRequired(t => t.HocKy)
                .WithMany(t => t.PhiMacDinhList)
                .HasForeignKey(d => d.MaHocKy);
            this.HasRequired(t => t.LopGoc)
                .WithMany(t => t.PhiMacDinhList)
                .HasForeignKey(d => d.MaLopGoc);

        }
    }
}
